# -*- coding:utf-8 -*-
# @Time:2023/9/17 15:31
# @Author: cevent
# @name=tasks 定义celery任务

from celery_task.sms.communicationCloud.SendTemplateSMS import SendSMS
from . import constants
from celery_task.main import celeryApp


# 发送短信验证码的异步任务
# 装饰器装饰异步任务，选用task函数，保证celery识别任务
@celeryApp.task(name='send_sms_code_celery_task')
def send_sms_code(mobile, shortCode):
    '''

    :param mobile: 手机号
    :param shortCode: 验证码
    :return: 成功：0，失败：-1
    '''
    print('开始celery异步任务发送----:', shortCode)
    sendResult = SendSMS().send(mobile, [shortCode, constants.SMS_CODE_REDIS_EXPIRES],
                                constants.SEND_SMS_TEMPLATE_ID)

    return sendResult
